package singleton;

/**
 * 无锁单例
 *
 * 目的: 避免同步锁 & 判断带来的开销
 * 实现:
 * 1. 声明时直接实例化
 * 
 * @author insight 
 * @since 2021/4/22
 */
public class SingletonWithoutSync {
    /**
     * 使用final关键字保证声明时直接实例化
     */
    private static final SingletonWithoutSync instance = new SingletonWithoutSync();;

    private SingletonWithoutSync() {
        System.out.println("SingletonWithoutSync is Instantiated!");
    }

    public static SingletonWithoutSync getInstance() { return instance; }
}